package com.hardydou.framework.humanskill.skill;

import cn.hutool.captcha.AbstractCaptcha;
import cn.hutool.captcha.CaptchaUtil;
import com.hardydou.framework.humanskill.HumanSkill;

/**
 * @author ：hardy
 * @description：图片识别技能
 * @date ：Created in 2020/6/13
 * @Copyright ：Hardydou.com
 */
public class ImageSkill extends HumanSkill {
    private final static String TYPE = "IMG";
    private String code;

    public ImageSkill() {
        AbstractCaptcha code = CaptchaUtil.createCircleCaptcha(120, 40);
        this.code = code.getCode().toUpperCase();
        this.data = code.getImageBase64();
    }

    @Override
    public String getType() {
        return TYPE;
    }


    @Override
    public boolean isHuman(String val) {
        return code.equals(val.toUpperCase());
    }
}
